<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
</html>
<script>
    function fn (str) {
        var res = str.split('&')
        var arr = []
        for ( var i = 0 ; i < res.length ; i++){
            var res1 = res[i].split('=')
            arr.push(...res1)
        }
        var obj = {}
        for(let j = 0 ; j < arr.length ; j++){
            if(j % 2 == 0){
                obj[arr[j]] = null
            }
            else{
                obj[arr[j - 1]] = arr[j]
            }
        }
        return obj
    }

    var str = 'name=1234&age=543'
    var res = fn (str)
    console.log(res);

</script>